const fs = require('fs')
const {faker} = require('@faker-js/faker')
const path = require('path')


faker.setLocale('zh_CN')
const db = {}
db.posts = []
for(let i = 0;i < 100;i++){
    db.posts.push({
        id:i + 1,
        title:faker.random.words(5),
        location:faker.address.cityName(),
        time:faker.date.past(),
        views:faker.random.numeric(4,{allowLeadingZeros:true}),
    })
}
// console.log(db)
fs.writeFileSync(path.resolve(__dirname,'db.json'),JSON.stringify(db))